package com.deke.course.service.Impl;

import com.aaa.common.entity.AclRole;
import com.aaa.common.entity.EduSubject;
import com.aaa.common.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.deke.course.dao.EduSubjectDao;
import com.deke.course.service.EduSubjectService;
import com.deke.course.vo.SubjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class EduSubjectServiceImpl implements EduSubjectService {
    @Autowired
    private EduSubjectDao subjectDao;


    @Override
    public Result findByConditionPage(SubjectVo subjectVo, Integer pageCurrent, Integer pageSize) {
        IPage<EduSubject> page=new Page<>(pageCurrent,pageSize);
        QueryWrapper<EduSubject> wrapper=new QueryWrapper<>();
        if(StringUtils.hasText(subjectVo.getTitle())){
            wrapper.like("title",subjectVo.getTitle());
        }
        if (subjectVo.getStatusId()!=null){
            wrapper.eq("status_id",subjectVo.getStatusId());
        }
        IPage<EduSubject> page1 = subjectDao.selectPage(page, wrapper);

        return new Result(200,"分页查询课程分类成功",page1);
    }
}
